package com.itheima10;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        // 创建客户端 socket 对象
        Socket s = new Socket("127.0.0.1", 10000);

        // 读取文件数据
        BufferedReader br = new BufferedReader(new FileReader("/Users/oscar/Desktop/HQWork/学习资料/code/MyNet/s.txt"));
        // 获取输出流
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));

        String line;
        while ((line = br.readLine()) != null) {
            bw.write(line);
            bw.newLine();
            bw.flush();
        }

        // 结束标记
        s.shutdownOutput();

        // 接收反馈
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String data = bufferedReader.readLine();
        System.out.println("服务端反馈：" + data);

        // 关闭资源
        br.close();
        s.close();
    }
}
